home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / fgl105c.zip / 05-14.C < prev    next >
Text File  |  1991-05-13  |  2KB  |  73 lines

  1. main()
  2. {
  3.    int mode, old_mode;
  4.    char string[5];
  5.  
  6. /* Ask for the video mode number */
  7.  
  8.    printf("Which video mode? ");
  9.    scanf("%d",&mode);
  10.  
  11. /* Make sure the entered value is valid */
  12.  
  13.    if (mode < 0 || mode > 21) {
  14.       printf("%d is not a valid video mode number.\n",mode);
  15.       exit();
  16.       }
  17.  
  18. /* Make sure the requested video mode is available */
  19.  
  20.    if (fg_testmode(mode,1) == 0) {
  21.       printf("Mode %d is not available on this system.\n",mode);
  22.       exit();
  23.       }
  24.  
  25. /* Establish the video mode */
  26.  
  27.    old_mode = fg_getmode();
  28.    fg_setmode(mode);
  29.  
  30. /* Perform mode-specific initializations */
  31.  
  32.    if (mode <= 3 || mode == 7)   /* text modes */
  33.       fg_cursor(0);
  34.  
  35.    else if (mode == 4 || mode == 5) { /* CGA color modes */
  36.       fg_palette(0,0);
  37.       fg_defcolor(14,3);
  38.       }
  39.  
  40.    else if (mode == 6) {         /* CGA two-color mode */
  41.       fg_palette(0,14);
  42.       fg_defcolor(14,1);
  43.       }
  44.  
  45.    else if (mode == 11)          /* Hercules mode */
  46.       fg_defcolor(14,1);
  47.  
  48.    else if (mode == 12)          /* Hercules low-res mode */
  49.       fg_defcolor(14,3);
  50.  
  51.    else if (mode == 17) {        /* VGA two-color mode */
  52.       fg_palette(1,14);
  53.       fg_setrgb(14,63,63,21);
  54.       fg_defcolor(14,1);
  55.       }
  56.  
  57. /* Display a message that includes the video mode number */
  58.  
  59.    fg_setcolor(14);
  60.    fg_text("I'm running in mode ",20);
  61.    sprintf(string,"%d. ",mode);
  62.    fg_text(string,3);
  63.  
  64. /* Wait for a keystroke */
  65.  
  66.    fg_waitkey();
  67.  
  68. /* Restore the original video mode and screen attributes */
  69.  
  70.    fg_setmode(old_mode);
  71.    fg_reset();
  72. }
  73.